function Cast(string Name)
{
	declare Index uint local 0
	if !${Me.CastingSpell} && ${Me.Ability[${Name}](exists)} && ${Me.Ability[${Name}].IsReady}
	{
		;call StopMoving
		call FaceTarget
		
		EA "Casting" "${Me.Ability[${Name}].Name}"
		Me.Ability[${Name}]:Use
		if ${Me.Ability[${Name}].CastingTime} > 0.000000
		{
			;EA "CastingTime" ${Math.Calc[${Me.Ability[${Name}].CastingTime}/1000]}
			while  ${Index:Inc} <= ${Math.Calc[${Me.Ability[${Name}].CastingTime}/1000]}
			{
				call FaceTarget
				waitframe
			}
		}
	}
	wait 5
}
function SpellCast(string Name)
{
	if ${Me.Ability[${Name}](exists)}
	{
		if ${Me.Health} >= ${Me.Ability[${Name}].HealthCost} && ${Me.Power} >= ${Me.Ability[${Name}].PowerCost} && (${Me.MaxConc} - ${Me.UsedConc}) >= ${Me.Ability[${Name}].ConcentrationCost}
		{
			call Cast "${Name}"
		}
	}
}
function CastOnSelf(string Name)
{
	call SpellCast "${Name}"
}
function CastOnTarget(string Name)
{
	if ${Target(exists)}
	{
		call SpellCast "${Name}"
	}
}
function BuffOnSelf(string Name, string RealName = "")
{
	if ${RealName.Equal[""]}
	{
		RealName:Set[${Name}]
	}
	if !${Me.Effect[${RealName}](exists)}
	{
		while ${Target.ID} != ${Me.ID}
		{
			Target "${Me.ID}"
		}
		call SpellCast "${Name}"
		while ${Me.CastingSpell}
		{
			wait 2
		}
	}
	call ClearTarget
}
function BuffOnTarget(string Name, string RealName = "")
{
	if ${RealName.Equal[""]}
	{
		RealName:Set[${Name}]
	}
	if ${Target(exists)} && ${Target.Health} > 0 && !${Target.Effect[${RealName}](exists)}
	{
		call SpellCast "${Name}"
	}
}
